package me.sealer.ssm.utils;

/**
 * 功能描述： $ SnookerUtil
 *
 * @author sealer
 * @email 1178884049@qq.com
 * @date 2019年12月06日 08时50分31秒
 */
public class SnookerUtil {
    public static final int RED_BALL_SCORE = 1;
    public static final int BLACK_BALL_SCORE = 7;
    public static final int A_SET_OF_BALL_SCORE = RED_BALL_SCORE + BLACK_BALL_SCORE;

    public static final int ALL_COLOR_BALL_SCORE = 27;

    /**
     * 计算斯诺克打到多少分超分
     * @param currentScore 当前打完彩球的得分数
     * @param leftRedBalls 剩余红球数
     * @return 达到多少分超分
     */
    public static final int calculateOverScore(int currentScore, int leftRedBalls) {
        int leftMaxScore = leftRedBalls * A_SET_OF_BALL_SCORE + ALL_COLOR_BALL_SCORE;
        int maxScoreCurrentPlayerCanGet = leftMaxScore + currentScore;
        int overScore = maxScoreCurrentPlayerCanGet / 2 + 1;
        return overScore;
    }

    public static void main(String[] args) {
        System.out.println("需要打到 " + calculateOverScore(0, 15) + "分才能超分。");
        System.out.println("需要打到 " + calculateOverScore(40, 2) + "分才能超分。");
    }
}
